﻿using System;
using System.Collections.Generic;
using ASPNETVN.PORTAL.Components.UI;
using ASPNETVN.PORTAL.Modules.ACTP.Components;

namespace ASPNETVN.PORTAL.Modules.ACTP.Controls
{
    public partial class TeamCalendar : ModulePage
    {
        protected string GetCalendarString()
        {
            string jqueryCalendar = string.Empty;
            IList<Project> projects = Project.SelectCollectionBy_TeamID(this.ItemID);
            foreach (Project project in projects)
            {
                jqueryCalendar += "{" + string.Format("id: {7}, title: '{0}', start: new Date({1}, {2}, {3}), end: new Date({4}, {5}, {6})", project.Code + " - " + project.Subject, project.StartDate.Year, project.StartDate.Month - 1, project.StartDate.Day, project.DueDate.Year, project.DueDate.Month - 1, project.DueDate.Day, project.ProjectID) + "},";
            }
            
            if (jqueryCalendar.LastIndexOf(",") > 0)
            {
                jqueryCalendar = jqueryCalendar.Remove(jqueryCalendar.LastIndexOf(","), 1);
            }
            return jqueryCalendar;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                TeamDetailControl1.TeamID = this.ItemID;
            }
        }
    }
}